package cpr.command;

import java.util.Iterator;
import java.util.Set;

import cpr.DefaultCommandHandler;
import cpr.Printer;
import cpr.data.SplitCluster;

public class CmdPrint extends DefaultCommandHandler {
	static final int PAGE_SIZE = 10;
	public CmdPrint() {
		super("print");
	}
	public void execute(String[] params) {
		int startFrom = Integer.parseInt( getParameter(params,1,"1"));
		
        Set set = getCommandContext().getContext().getCurrentWorksetContext().getClusterSet();
        
        int cnt = 1;
        for (Iterator iter = set.iterator(); iter.hasNext();) {
            SplitCluster c =  (SplitCluster)iter.next();
        	if (cnt>=startFrom) {
                if (cnt>PAGE_SIZE+startFrom-1) {
                	Printer.println(""+(set.size()-cnt+1)+" more...");
                	break;
                }
               Printer.println(cnt+". "+ c.aRule.ruleNrGlobal+". " +getCommandContext().getContext().getPrintContext().printRuleUsingDict(c.aRule, c.aVector)+" x "+ c.getCounter());
        	}
            cnt++;
            
        }
    }
	
}
